package com.ruoyi.receipt.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.receipt.domain.SysReceipt;
import com.ruoyi.receipt.service.ISysReceiptService;
import com.ruoyi.weigh.domain.SysWeigh;
import com.ruoyi.weigh.service.ISysWeighService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 收货统计(记录)管理Controller
 * 
 * @author ruoyi
 * @date 2023-11-21
 */
@RestController
@RequestMapping("/system/receipt")
public class SysReceiptController extends BaseController
{
    @Autowired
    private ISysReceiptService sysReceiptService;

    @Autowired
    private ISysWeighService sysWeighService;

    /**
     * 查询收货统计(记录)管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:receipt:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysWeigh sysWeigh)
    {
        startPage();
        System.out.println(sysWeigh);
        List<SysWeigh> list = sysWeighService.selectSysReceiptList(sysWeigh);
        return getDataTable(list);
    }

    /**
     * 导出收货统计(记录)管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:receipt:export')")
    @Log(title = "收货统计(记录)管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysReceipt sysReceipt)
    {
        List<SysReceipt> list = sysReceiptService.selectSysReceiptList(sysReceipt);
        ExcelUtil<SysReceipt> util = new ExcelUtil<SysReceipt>(SysReceipt.class);
        util.exportExcel(response, list, "收货统计(记录)管理数据");
    }

    /**
     * 获取收货统计(记录)管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:receipt:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysReceiptService.selectSysReceiptById(id));
    }

    /**
     * 新增收货统计(记录)管理
     */
    @PreAuthorize("@ss.hasPermi('system:receipt:add')")
    @Log(title = "收货统计(记录)管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysReceipt sysReceipt)
    {
        return toAjax(sysReceiptService.insertSysReceipt(sysReceipt));
    }

    /**
     * 修改收货统计(记录)管理
     */
    @PreAuthorize("@ss.hasPermi('system:receipt:edit')")
    @Log(title = "收货统计(记录)管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysReceipt sysReceipt)
    {
        return toAjax(sysReceiptService.updateSysReceipt(sysReceipt));
    }

    /**
     * 删除收货统计(记录)管理
     */
    @PreAuthorize("@ss.hasPermi('system:receipt:remove')")
    @Log(title = "收货统计(记录)管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysReceiptService.deleteSysReceiptByIds(ids));
    }
}
